#!usr/bin/perl -w

#定义了Query类
package Query;

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(Id Default Pattern Value);
use strict;

sub new()
{
	my $class=shift;
	my $self={};
	bless $self,$class;
	$self->Construct(@_);
	return $self;
}

sub Construct()
{
	my $this=shift;
	my ($id,$default,$pattern,$value)=@_;
	$this->{'iId'}=$id;
	$this->{'iDefault'}=$default;
	$this->{'iPattern'}=$pattern;
	$this->{'iValue'}=$value;
}

sub Id()
{
	my $this=shift;
	my ($id)=@_;
	if ($id)
	{
		$this->{'iId'}=$id;
	}
	return $this->{'iId'};
}

sub Default()
{
	my $this=shift;
	my ($default)=@_;
	if ($default)
	{
		$this->{'iDefault'}=$default;
	}
	return $this->{'iDefault'};
}

sub Pattern()
{
	my $this=shift;
	my ($pattern)=@_;
	if ($pattern)
	{
		$this->{'iPattern'}=$pattern;
	}
	return $this->{'iPattern'};
}

sub Value()
{
	my $this=shift;
	my ($value)=@_;
	if ($value)
	{
		$this->{'iValue'}=$value;
	}
	return $this->{'iValue'};
}

sub Parse()
{
	my $this=shift;
	my ($ref)=@_;

	if (defined $ref->{'pattern'})
	{
		$this->Pattern($ref->{'pattern'});
	}
	elsif (defined $ref->{'id'})
	{
		$this->Id($ref->{'id'});
	}
	elsif (defined $ref->{'default'})
	{
		$this->Default($ref->{'default'});
	}
}

1;

